#!/bin/bash
# 寻找工作空间目录,如果不存在则设置默认目录
if [ "$ws_path" != "" ]; then
    echo "检测到工作空间目录:$ws_path"
else
    ws_path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
    ws_path=$(dirname $ws_path)
    # 设置为全局变量
    export ws_path
    echo "设置工作空间目录:$ws_path"
fi
cd $ws_path
# 后台运行训练脚本(-u禁用输出缓冲)
nohup python -u scripts/train_0.py > train.log 2>&1 &
# 输出并保存PID
echo $! > train.pid
echo "训练脚本已启动,PID: $!"
# 实时监控日志
tail -f --pid=$(cat train.pid) --sleep-interval=0.1 train.log
cd -